package com.ljfiction.book.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.MessageBean;
import com.ljfiction.book.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Android on 2017/12/19.
 */

public class MessageAdapter extends BaseMultiItemQuickAdapter<MessageBean.DataBean.ListBean,BaseViewHolder> {


    public MessageAdapter(List<MessageBean.DataBean.ListBean> data) {
        super(data);
        addItemType(0, R.layout.message_he);
        addItemType(1, R.layout.message_my);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageBean.DataBean.ListBean item) {
        AutoUtils.autoSize(helper.itemView);
        switch (helper.getItemViewType()) {
            case 0:
                Glide.with(mContext).load(item.getUserImage()).into((ImageView) helper.getView(R.id.messagehe_image));
                helper.setText(R.id.messagehe_text,item.getMessageContent());
                break;
            case 1:
                Glide.with(mContext).load(item.getUserImage()).into((ImageView) helper.getView(R.id.messagemy_image));
                helper.setText(R.id.messagemy_text,item.getMessageContent());
                break;
        }


    }
}
